<?php
class AvailableLanguages extends DatabaseTable {

    public function __construct($conn) {
        parent::__construct($conn);
    }

    protected function load(){
        $query=sprintf("SELECT * FROM 	%s",
            mysql_real_escape_string("available_languages"));
	$result=mysql_query($query,$this->conn);
	if ($result){
            while ($row = mysql_fetch_assoc($result)) {
                $id=$row['id'];
                $code=$row['code'];
                $text=$row['text'];                
                $newl= new Language();
                $newl->setId($id);
                $newl->setCode($code);
                $newl->setText($text);
                $this->records[$id] = $newl;
            }
        }
	mysql_free_result($result);
    }

    public function isSupported($lang){
        foreach ($this->getAll() as $key => $value) {
            if (stristr($value->getCode(),$lang))
                return $key;
        }
        return -1;
    }
}
?>
